//
//  XJCommunityIWantServeSuccessView.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/6/1.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJCommunityIWantServeSuccessView.h"

@interface XJCommunityIWantServeSuccessView()

/**成功图片*/
@property(nonatomic, strong) UIImageView *successImageView;
/**2.tipsLabel*/
@property(nonatomic, strong) UILabel *tipsLabel;
/**3.返回社区按钮*/
@property(nonatomic, strong) UIButton *backCommunityButton;
/**4.继续提交*/
@property(nonatomic, strong) UIButton *goOnSubmitButton;

@end
@implementation XJCommunityIWantServeSuccessView

#pragma mark - 一 初始化
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setupView {
    [self addSubview:self.successImageView];
    [self addSubview:self.tipsLabel];
    [self addSubview:self.backCommunityButton];
    [self addSubview:self.goOnSubmitButton];
}

#pragma mark - 二 lazy
- (UIImageView *)successImageView {
    if (!_successImageView) {
        _successImageView = [[UIImageView alloc] init];
        _successImageView.backgroundColor = [UIColor lightGrayColor];
    }
    return _successImageView;
}

- (UILabel *)tipsLabel {
    if (!_tipsLabel) {
        _tipsLabel = [[UILabel alloc] init];
        _tipsLabel.numberOfLines = 0;
        _tipsLabel.textAlignment = NSTextAlignmentCenter;
        _tipsLabel.font = [UIFont systemFontOfSize:14.0];
        _tipsLabel.text = @"已提交申请\n点击继续提价可再次提交其他服务";
    }
    return _tipsLabel;
}
- (UIButton *)backCommunityButton {
    if (!_backCommunityButton) {
        _backCommunityButton = [UIButton buttonWithFrame:CGRectZero target:self action:@selector(backCommunityButtonAction) bgc:nil title:@"返回社区"];
    }
    return _backCommunityButton;
}

- (UIButton *)goOnSubmitButton{
    if (!_goOnSubmitButton) {
        _goOnSubmitButton = [UIButton buttonWithFrame:CGRectZero target:self action:@selector(goOnSubmitButtonAction) bgc:[UIColor yellowColor] title:@"继续提交"];
    }
    return _goOnSubmitButton;
}


#pragma mark - 三 layout

- (void)layoutSubviews {
    [super layoutSubviews];
    
    
    [self.successImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(150);
        make.size.mas_equalTo(CGSizeMake(130, 130));
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    [self.tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(self.successImageView.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(220, 60));
    }];
    
    [self.backCommunityButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.tipsLabel.mas_left);
        make.top.equalTo(self.tipsLabel.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(100, 30));
    }];
    [self.goOnSubmitButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.tipsLabel.mas_right);
        make.top.equalTo(self.tipsLabel.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(100, 30));
    }];
}
#pragma mark - 四 点击事件
- (void)backCommunityButtonAction{
    if (self.backButtonBlock) {
        self.backButtonBlock();
    }
}

- (void)goOnSubmitButtonAction{
    if (self.goOnButtonBlock) {
        self.goOnButtonBlock();
    }
}


@end
